#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
bool cmp(pair<int,int>a,pair<int,int>b);

int main()
{
    map<int,int> mp;//创建映射
    mp[0];//仅访问时会创建一个键并赋值为0,不能用迭代器查找下标
    cout<<mp.count(0)<<endl;
    string s;
    char buf[100];
    scanf("%s",&buf);
    s = buf;//buf为缓存

    printf("%s\n",s.c_str());
    //getline(cin,s);
    //cin<<s;
    //cout<<s<<endl;
    string s1(100,'0');
    s1 = "1231232123";//赋值
    cout<<s1<<endl;
    s1[0] = 'b';//修改
    cout<<s1<<endl;
    string s2 ;
    s2 = "bwa";
    
    if(s1==s2)
    {
        cout<<"yes"<<endl;

    }
    s1+= 'a';//尾接
    cout<<s1+s2<<endl;//连接字符串
    cout<<s1.substr(3,5)<<endl;//(索引，读取的数量)
    s1 = "1231232123";
    cout<<s1.find("312")<<endl;
    if(s1.find("312")!=string::npos)//not a position
    {
        cout<<"yes"<<endl;
    }
    int x = stoi(s1);
    //long long x = stoll(s1);

    cout<<s1<<endl;
    int k  = 66662;
    string k1 ;
    k1 = to_string(k);
    cout<<k1<<endl;







    pair<char,int> p3 = {'a',2};
    pair<int,int>p1 = {1,2};//二元组
    pair<int,int>p2 = {1,2};//二元组
    pair<pair<char,int>,int> p4;//三元组



    //pair<int,int>p = make_pair(1,2);//二元组(老式)
    cout<<p1.first<<" "<<p1.second<<endl;
    //判同
    if(p1 == p2)
    {
        cout<<"yes"<<endl;
    }
    
    int a = 1;
    int b = 2;
    cout<<a<<" "<<b<<endl;
    
    swap(a,b);
    cout<<a<<" "<<b<<endl;
    vector<int> arr = {1,9,1,9,8,1,0};
    // sort(arr.begin(),arr.end(),greater<int>());//从大到小
    // for(int i = 0;i<arr.size();i++)
    // {
    //     cout<<arr[i]<<endl;
    // }
    vector<pair<int,int>> arr6 {{1,9},{2,9},{8,1},{0,0}  };
    sort(arr6.begin(),arr6.end(),cmp);
    for(auto ele:arr6)
    {
        cout<<ele.first<<" "<<ele.second<<endl;

    }
    //二分查找
    //使用前确保所有元素有序
    vector<int> arrk{0,1,1,1,8,9,9};
    int pos = lower_bound(arrk.begin(),arrk.end(),8) - arrk.begin();//第一个大于等于8的位置
    int pos2 = upper_bound(arrk.begin(),arrk.end(),8) - arrk.begin();//第一个小于等于8的位置
    int pos3 = upper_bound(arrk.begin(),arrk.end(),88888) - arrk.begin();//
    //起点终点可变
    //找不到数字返回尾迭代器
    if (pos3 == arrk.size())
    {
        cout<<"no"<<endl;
    }
    //reverse反转
    reverse(arrk.begin()+2,arrk.begin()+5);//反转第二位到第四位
    //起点终点可变
    
    for(auto ele:arrk)
    {
        cout<<ele<<endl;
    }
    cout<<pos<<endl;
    cout<<pos2<<endl;


    cout<<min(min(1,3),2)<<endl;
    cout<<min({1,3,4})<<endl;//c++11
    //unique()消除相邻重复元素，单独使用无去重效果
    //去重
    vector<int> arrq{1,2,1,4,5,4,4};
    sort(arrq.begin(),arrq.end());
    arrq.erase(unique(arrq.begin(),arrq.end()),arrq.end());
    for(auto &elee:arrq)
    {
        cout<<elee<<endl;
    }

    //1 2 1 4 5 4 4
    //1 1 2 4 4 4 5
    //1 2 4 5 * * *(无效数据)
    int kk = __gcd(8,12);
    printf("%d\n",kk);
    //gcd(a,b)求最大公因数，lcm（a，b）求最小公倍数（c++17）
    

    return 0;
    
}


bool cmp(pair<int,int>a,pair<int,int>b)
{
    if(a.second!= b.second)
    {
        return a.second<b.second;
    }
    return a.first>b.first;


}